package Utils.Gameplay;

import datatypes.Datatypes.tableType;

/**
 * QueryContext represents a query context from which the database client can
 * understand the appropriate query request details, and generate the result
 * 
 * @author Micha
 * 
 */
public class QueryContext {

	/**
	 * the context identification
	 * 
	 * in case contextId equals null, a random entity should be returned
	 */
	private String contextId;

	/**
	 * question context (i.e the known part of the question)
	 */
	private tableType context;

	/**
	 * context connector (i.e some other type that the context is connected to)
	 * 
	 * the connector represents the unknown part of the question
	 */
	private tableType connector;

	public QueryContext(String contextId, tableType context, tableType connector) {

		setContextId(contextId);
		setContext(context);
		setConnector(connector);
	}

	public tableType getContext() {
		return context;
	}

	public void setContext(tableType context) {
		this.context = context;

	}

	public tableType getConnector() {
		return connector;
	}

	public void setConnector(tableType connector) {
		this.connector = connector;
	}

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();

		if (contextId != null && contextId.length() > 0) {
			sb.append("context id : " + getContextId() + "\n");
		}

		sb.append("context: " + this.context.getTableName() + "\n");
		sb.append("connector: " + this.connector.getTableName() + "\n");
		return sb.toString();
	}

	public String getContextId() {
		return contextId;
	}

	public void setContextId(String contextId) {
		this.contextId = contextId;
	}

}
